<template>
  <div style="background-color: rgb(245, 245, 245)">
    <div id="product_exhibition">
      <div class="content">
        <div
          class="yige"
          v-for="(item, index) in nei"
          :key="index"
          @click="dianjin(item.gid)"
        >
          <img class="shop_photo" :src="item.imagepath1" />
          <p class="goods_name">{{ item.goodsname }}</p>
          <div class="shop_price_big">
            <div class="fu1">
              <p class="fu">￥</p>
              <div style="width: 7px"></div>
              <p style="font-size: 20px; font-weight: 600; color: red">
                {{ item.goodsprice }}
              </p>
              <p class="goods_price"></p>
            </div>
            <p class="sales">{{ item.salesvolume }}人已购买</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>

import { Shopping_page } from "../api/Shopping";
export default {
  data() {
    return {
      nei: [],
      uid: "",
      gid:''
    };
  },
  methods: {
    xuan() {
      let data = JSON.parse(localStorage.getItem("userid"));
      this.uid =  data + "";
      Shopping_page({
        uid: this.uid,
      })
        .then((res) => {
          this.nei = res.data;

        })
        .catch((rest) => {
          console.log(rest);
        });
    },
    dianjin(a) {
      console.log(a);
      this.gid = a
      console.log(this.gid);
      localStorage.setItem("gid", this.gid);
      this.$router.push('/ShopMain')
      // console.log(localStorage.setItem("gid", this.gid));
      // this.$router.push({
      //   name: "ShopMain",
      //   params: {
      //     a: a,
      //     },
      // });
      // console.log(a);
    },
  },
  mounted() {
    this.xuan();
  },
};
</script>

<style scoped>
#product_exhibition {
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: space-evenly;
}
.content {
  width: 370px;
  display: flex;
  justify-content: space-between;
  flex-direction: row;
  flex-wrap: wrap;
}

.yige {
  width: 180px;
  height: 300px;
  background-color: rgb(255, 255, 255);
  border-radius: 10px;
  margin-top: 5px;
  margin-bottom: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
}
.yige img {
  width: 100%;
  height: 170px;
}
.goods_name {
  font-size: 14px;
  padding: 3px;
  text-align: center;
}
.fu1 {
  height: 20px;
  width: 150px;
  display: flex;
  align-items: center;
}
.shop_price_big {
  width: 171px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.fu {
  font-size: 14px;
}
.goods_price {
  font-size: 19px;
  font-weight: 600;
}
.sales {
  font-size: 13px;
  white-space: nowrap;
}
</style>
